package com.onairm.baselibrary;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;

import com.net.cache.db.DaoMaster;
import com.net.cache.db.DaoSession;
import com.onairm.baselibrary.net.RetrofitManager;
import com.onairm.baselibrary.utils.CrashHandler;
import com.onairm.baselibrary.utils.SpUtil;
import com.onairm.baselibrary.utils.TipToast;
import com.onairm.baselibrary.utils.Utils;
import com.orhanobut.logger.LogLevel;
import com.orhanobut.logger.Logger;

/**
 * Created by Edison on 2017/2/23.
 */

public class Init {
    public final static String TAG = "tag";
    private volatile static Init init;

    //必须从外部传进来
    public static Context context;

    private Init() {
    }

    public static Init getInstance() {
        if (init == null) {
            synchronized (Init.class) {
                if (init == null) {
                    init = new Init();
                }
            }
        }
        return init;
    }

    public void init(Context context, String baseUrl) {
        this.context = context;
        TipToast.init(context);
        SpUtil.init(context);
        if (Utils.isDebug(context)) {
            Logger.init(TAG).logLevel(LogLevel.FULL);
            CrashHandler.getInstance().init(context, "base");
        } else {
            Logger.init(TAG).logLevel(LogLevel.NONE);
        }

        RetrofitManager.setBaseUrl(baseUrl);
    }
}
